﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QuanLyDoanVien.General;
using QuanLyDoanVien.Bussiness;
using QuanLyDoanVien.Controller;
using DevComponents.DotNetBar;

namespace QuanLyDoanVien
{
    public partial class frmRaTruong : Form
    {
        LopCtrl m_Lop_Ctrl = new LopCtrl();
        List<HocSinhInfo> ds_hs = new List<HocSinhInfo>();
        HocSinhCtrl m_HocSinhCtrl = new HocSinhCtrl();

        public frmRaTruong()
        {
            InitializeComponent();
            DataService.OpenConnection();
        }
        private void Load_DS_Lop(String malop)
        {
            ds_hs = m_HocSinhCtrl.layHocSinhTheoLop(malop);
            this.dataGridView_HS_Lop.Rows.Clear();
            foreach (HocSinhInfo hs in ds_hs)
            {
                dataGridView_HS_Lop.Rows.Add(hs.MaHocSinh, hs.HoTen, hs.MaLop, hs.GioiTinh, hs.NgaySinh, hs.NoiSinh, hs.NgayVaoDoan, hs.MaChucVu, hs.HoTenCha, hs.HoTenMe);
            }
        }
       

        private void frmRaTruong_Load(object sender, EventArgs e)
        {
            m_Lop_Ctrl.HienThiComboBox(this.cmb_Lop);
            Load_DS_Lop(this.cmb_Lop.SelectedValue.ToString());

        }

        private void cmb_Lop_SelectedIndexChanged(object sender, EventArgs e)
        {
            Load_DS_Lop(this.cmb_Lop.SelectedValue.ToString());
        }

        private void btn_L_CapNhat_Click(object sender, EventArgs e)
        {
            if (this.chx_RaTruong.Checked == true)
            {
                m_HocSinhCtrl.DanhDau_RaTruong(this.cmb_Lop.SelectedValue.ToString(), 1);
                MessageBoxEx.Show("Đánh dấu lớp đã ra trường thành công", "Thông báo");
                //this.chx_RaTruong.Checked = false;
            }
            else
            {
                m_HocSinhCtrl.DanhDau_RaTruong(this.cmb_Lop.SelectedValue.ToString(), 0);
                MessageBoxEx.Show("Lấy lại danh dách học sinh đã ra trường", "Thông báo");
            }
            Load_DS_Lop(this.cmb_Lop.SelectedValue.ToString());
        }
    }
}
